package com.guigu.xiaowenbo.controller;

import com.guigu.liuzhireng.pojo.Account;
import com.guigu.tankai.pojo.Dfile;
import com.guigu.util.PageVo;
import com.guigu.xiaowenbo.service.DfilerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpSession;

@Controller
public class DfilerController {
    @Autowired
    DfilerService dflierService;
    @RequestMapping("selectByPrimaryKeyXWB")
    @ResponseBody
    public PageVo selectByPrimaryKeyXWB(@RequestBody PageVo<Dfile> dfile){
        return dflierService.selectByPrimaryKeyXWB(dfile.getNum(),dfile.getSize());
    }
    @RequestMapping("/selectByPrimaryKeyid")
    public ModelAndView selectByPrimaryKeyid(String productid, HttpSession session){
        String acc = ((Account) session.getAttribute("user")).getAccount();
        ModelAndView modelAndView = new ModelAndView();
        Dfile dfile = dflierService.selectByPrimaryKeyid(productid);
        modelAndView.setViewName("xiao_wen_bo/demo.jsp");
        modelAndView.addObject("dfile",dfile);
        modelAndView.addObject("name",acc);
        return modelAndView;
    }

}
